<template>
  <div class="common-table">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column show-overflow-tooltip v-for="item in tableLabel" :key="item.prop" :label="item.label" :width="item.width ? item.width : 100 ">
      <template slot-scope="scope">
      <span style="margin-left: 10px;">{{scope.row[item.prop]}}</span>
      </template>
      </el-table-column>
        <el-table-column
                label="角色">
            <template slot-scope="scope">
                <el-select v-model="scope.row.role" value-key="id" multiple placeholder="请选择" @change="changeRole(scope.row)" style="width: 120px;">
                    <el-option
                            v-for="item in options"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                    </el-option>
                </el-select>
            </template>
        </el-table-column>
      <el-table-column label="操作" min-width="180">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
  <el-pagination :page-size="config.pageSize" :pager-count="5"
    layout="prev, pager, next" :current-page="config.page" @current-change="changePage"
    :total="config.total">
  </el-pagination>
</div>
  </div>

</template>
<script>
export default {
  name: 'CommonTable',
  data() {
    return {
    }
  },
  props: {
    tableData: Array,
    tableLabel:Array,
    config: Object,
    options:Array

  },
  methods: {
    handleEdit(row) {
      this.$emit('edit', row)
    },
    handleDelete(row) {
      this.$emit('del', row)
    },
    changePage(page){
      this.config.page=page
      this.$emit('changePage',page)
    },
    changeRole(row){
      console.log(row);
      this.$emit('changeRole',row)
    }
  },

}
</script>

<style lang="less" scoped>
.common-table {
  height: calc(100% - 62px);
  background-color: #fff;
  position: relative;

  .pager {
    position: absolute;
    bottom: 0;
    right: 20px;
  }
}
</style>